typedef struct {
    int *data;
    int front;
    int rear;
} RecentCounter;


RecentCounter* recentCounterCreate() {
      RecentCounter* q=(RecentCounter *)malloc(sizeof(RecentCounter));
      q->data=(int *)malloc(sizeof(int)*10000);
      q->front=0;
      q->rear=0;
      return q;
}

int recentCounterPing(RecentCounter* obj, int t) { 
      obj->data[obj->rear]=t;
      obj->rear++;
      while(t-obj->data[obj->front]>3000){
        obj->front++;
      }
      return obj->rear-obj->front;
}

void recentCounterFree(RecentCounter* obj) {
      free(obj->data);
      free(obj);
}
